#pragma once

#include <string>

namespace CwRedis {

    class RedisConnConfig {

    public:

        /**
          * @brief  构造一个默认的redis连接选项
          * @note   默认的ip为127.0.0.1，用户为default，端口为6379，密码为空
          */
        RedisConnConfig() = default;

        RedisConnConfig(const RedisConnConfig &) = default;

        RedisConnConfig(RedisConnConfig &&) = default;

        RedisConnConfig &operator=(const RedisConnConfig &) = default;

        ~RedisConnConfig() = default;

        /**
          * @brief  根据指定ip和端口构造一个redis连接选项
          * @param  ip和端口
          */
        explicit RedisConnConfig(const char *ip, unsigned int port = 6379)
                : ip_(ip), port_(port) {}

        explicit RedisConnConfig(std::string ip, unsigned int port = 6379)
                : ip_(std::move(ip)), port_(port) {}

        /**
          * @brief  根据指定ip，密码和端口构造一个redis连接选项
          * @param  ip,密码和端口
          */
        RedisConnConfig(const char *ip, const char *password, unsigned int port = 6379)
                : ip_(ip), password_(password), port_(port) {}

        RedisConnConfig(std::string ip, std::string password, unsigned int port = 6379)
                : ip_(std::move(ip)), password_(std::move(password)), port_(port) {}

        /**
          * @brief  根据指定ip，用户名，密码和端口构造一个redis连接选项
          * @param  ip，用户名，密码和端口
          */
        RedisConnConfig(const char *ip, const char *user, const char *password, unsigned int port = 6379)
                : ip_(ip), user_(user), password_(password), port_(port) {}

        RedisConnConfig(std::string ip, std::string user, std::string password, unsigned int port = 6379)
                : ip_(std::move(ip)), user_(std::move(user)), password_(std::move(password)), port_(port) {}

        /**
          * @brief  geter和seter方法
          */
        std::string getIp() const { return ip_; }

        void setIp(const char *ip) { ip_ = ip; }

        void setIp(const std::string &ip) { ip_ = ip; }

        std::string getUser() const { return user_; }

        void setUser(const char *user) { user_ = user; }

        void setUser(const std::string &user) { user_ = user; }

        std::string getPassword() const { return password_; }

        void setPassword(const char *password) { password_ = password; }

        void setPassword(const std::string &password) { password_ = password; }

        unsigned int getPort() const { return port_; }

        void setPort(unsigned int port) { port_ = port; }

    private:

        // redis服务器ip
        std::string ip_ = "127.0.0.1";

        // redis用户名
        std::string user_ = "default";

        // redis连接密码
        std::string password_;

        // redis服务器端口
        unsigned int port_ = 6379;

    };
}